<%--
  Created by IntelliJ IDEA.
  User: 75880
  Date: 2024/8/17
  Time: 0:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改图书</title>
    <%
        String base = request.getContextPath() + "/";
        String url = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + base;
    %>
    <base href="<%=url%>">
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            <%String bookId = request.getParameter("bookId");%>
            $.get("book/selectById",{"bookId":<%=bookId%>},function (book) {
                $("[name='bookName']").val(book.bookName);
                $("[name='bookAuthor']").val(book.bookAuthor);
                $("[name='bookPublish']").val(book.bookPublish);
                $("[name='bookPage']").val(book.bookPage);
                $("[name='bookPrice']").val(book.bookPrice);
                $("[name='createDate']").val(book.createDate);

            })

            $("[value='修改']").click(function () {
                var bookName=$("[name='bookName']").val();
                var bookAuthor=$("[name='bookAuthor']").val();
                var bookPublish=$("[name='bookPublish']").val();
                var bookPage=$("[name='bookPage']").val();
                var bookPrice=$("[name='bookPrice']").val();
                var createDate=$("[name='createDate']").val();
                $.get("book/updateBook",{"bookName":bookName,"bookAuthor":bookAuthor,"bookPublish":bookPublish,"bookPage":bookPage,"bookPrice":bookPrice,"bookId":<%=bookId%>,"createDate":createDate},
                function (boo) {
                    if(boo) {
                        alert("修改成功")
                    }else {
                        alert("修改失败")
                    }
                    window.location.href="index.jsp"
                })
            })
        })


    </script>


</head>
<body>
书名:<input type="text" name="bookName"><br>
作者:<input type="text" name="bookAuthor"><br>
出版社:<input type="text" name="bookPublish"><br>
页数:<input type="text" name="bookPage"><br>
价格:<input type="text" name="bookPrice"><br>
创建时间:<input type="date" name="createDate"><br>
<input type="button" value="修改">
</body>
</html>
